package jdk8的特性.Stream.求和;

import java.util.Arrays;

/**
 * @author idea
 * @data 2018/9/15
 */
public class Test {
    public static void main(String[] args) {
        int total=0;
        int[] numbers={1,2,3,4,5,6,7,8,9,10};
        //求和的计算方式
        int sum= Arrays.stream(numbers).reduce(0,(s,b)->s+b);
        System.out.println(sum);
        //求和的计算方式
        total=Arrays.stream(numbers).reduce(0,Integer::sum);
        System.out.println(total);
        //求最小值
        int min=Arrays.stream(numbers).reduce(0,Integer::min);
        //求最大值
        int max=Arrays.stream(numbers).reduce(0,Integer::max);
        System.out.println("max: "+max+" min:"+min);
    }

}
